/*
 * IUnit.h
 *
 *  Created on: 07.12.2011
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#ifndef IUNIT_H_
#define IUNIT_H_

#include "../BasicTypes.h"
#include "../TStack.h"
#include "CTemplateCollection.h"
#include "../Visualisator/GameObject.h"
#include "../Dynamic System/IAnimationPlayer.h"
#include "../Dynamic System/Physics Engine/CPhysicsController.h"
#include "../Dynamic System/IUnitDriver.h"

#include <queue>
#include <string>

const UINT UNITS_DEFAULT_STACK_SIZE = 15;

class CPhisicEngine
{
	CPhisicEngine(){};
	~CPhisicEngine(){};
};

class IUnit
{
friend class CTemplateCollection;
private:
	//CAnimationController* animationController;
	//CPhysicsController*   physicsController;
	IUnitDriver*          unitDriver;
	GAME_OBJECT*          visualisationInfo;

	std::string            name;
	UNIT_INITIAL_PHYSIC_PARAMS*    physicParams;
	std::queue<UINT_EVENT> eventQueue;
	std::vector<TEXTURE_DESCRIPTOR> textures;
	bool                            sequenceStarted;

protected:
	IUnit( GAME_OBJECT* VisualisationInfo, IUnitDriver* UnitDriver );
	IUnit( const IUnit& Base );
	virtual ~IUnit();

	virtual void MakeClone( CTemplateCollection* Collection ) const = 0;
	virtual bool SetName( const std::string Name );
	virtual bool SetPhysicParams( const UNIT_INITIAL_PHYSIC_PARAMS &PhysicParams );

public:
	virtual const std::string GetName() const;

	virtual void PushEvent( UINT_EVENT Event ){ eventQueue.push( Event ); };
	virtual UINT_EVENT PopEvent();

	virtual IUnitDriver* GetUnitDriver() { return unitDriver; };
	virtual GAME_OBJECT* GetVisualInfo() { return visualisationInfo; };

	virtual void Rotate( UINT Axis, float Angle ){};
	virtual void Translate( const glm::vec3 Translation );

	virtual void StartUpdatingSequence();
	virtual void FinishUpdatingSequence();
	virtual bool UpdateTexture( const TEXTURE_DESCRIPTOR &Texture, const UINT Subobject );
};

#endif /* IUNIT_H_ */
